package org.springblade.modules.ad.controller;

import org.springblade.modules.ad.entity.AdUser;
import org.springblade.modules.ad.service.AdUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * AD 用户 Controller
 * @ClassName AdUserController.java
 * @version 1.0.0
 * @author zhangyunjiao
 * @createTime 2021/8/26
 */
@RestController
@RequestMapping("/blade-test")
public class AdUserController {
	@Resource
	private AdUserService ldapService;


	/**
	 * 添加OU 用户
	 * @param adUser
	 */
	@PostMapping(value = "/addAdUser")
	public void addAdUser(@RequestBody AdUser adUser){
		ldapService.addAdUser(adUser);
	}


	/**
	 * 用户切换OU 层级
	 * @param ldapUser
	 */
	@PostMapping(value = "/changeUserOu")
	public void changeUserOu(@RequestBody AdUser ldapUser){
		ldapService.changeUserOu(ldapUser);
	}


	/**
	 * AD 用户属性修改
	 * @param ldapUser
	 */
	@PostMapping(value = "/modifyAdUser")
	public void modifyPerson(@RequestBody AdUser ldapUser){
		ldapService.modifyPerson(ldapUser);
	}



	/**
	 * AD 用户密码
	 * @param ldapUser
	 */
	@PostMapping(value = "/modifyUserPwd")
	public void modifyAdUser(@RequestBody AdUser ldapUser){
		ldapService.modifyUserPwd(ldapUser);
	}


	/**
	 * 用户禁用
	 * @param ldapUser
	 */
	@PostMapping(value = "/delete")
	public void delete(@RequestBody AdUser ldapUser){
		ldapService.deletePerson(ldapUser);
	}


	/**
	 * 根据名称查找用户
	 * @param adUser
	 * @return
	 */
	@RequestMapping(value = "/findOne",method = RequestMethod.GET)
	public AdUser findByCn(@RequestBody AdUser adUser){
		return ldapService.findByCn(adUser);
	}

}
